package io.xccit.race.service.impl;

import java.util.List;
import io.xccit.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import io.xccit.race.mapper.RaceCompetitionTopicMapper;
import io.xccit.race.domain.RaceCompetitionTopic;
import io.xccit.race.service.IRaceCompetitionTopicService;

/**
 * 竞赛试题Service业务层处理
 * 
 * @author ywx
 * @date 2025-10-10
 */
@Service
public class RaceCompetitionTopicServiceImpl implements IRaceCompetitionTopicService 
{
    @Autowired
    private RaceCompetitionTopicMapper raceCompetitionTopicMapper;

    /**
     * 查询竞赛试题
     * 
     * @param id 竞赛试题主键
     * @return 竞赛试题
     */
    @Override
    public RaceCompetitionTopic selectRaceCompetitionTopicById(Long id)
    {
        return raceCompetitionTopicMapper.selectRaceCompetitionTopicById(id);
    }

    /**
     * 查询竞赛试题列表
     * 
     * @param raceCompetitionTopic 竞赛试题
     * @return 竞赛试题
     */
    @Override
    public List<RaceCompetitionTopic> selectRaceCompetitionTopicList(RaceCompetitionTopic raceCompetitionTopic)
    {
        return raceCompetitionTopicMapper.selectRaceCompetitionTopicList(raceCompetitionTopic);
    }

    /**
     * 根据竞赛ID查询试题列表
     * 
     * @param competitionId 竞赛ID
     * @return 竞赛试题集合
     */
    @Override
    public List<RaceCompetitionTopic> selectRaceCompetitionTopicByCompetitionId(Long competitionId)
    {
        return raceCompetitionTopicMapper.selectRaceCompetitionTopicByCompetitionId(competitionId);
    }

    /**
     * 新增竞赛试题
     * 
     * @param raceCompetitionTopic 竞赛试题
     * @return 结果
     */
    @Override
    public int insertRaceCompetitionTopic(RaceCompetitionTopic raceCompetitionTopic)
    {
        raceCompetitionTopic.setCreateTime(DateUtils.getNowDate());
        raceCompetitionTopic.setDelFlag("0");
        return raceCompetitionTopicMapper.insertRaceCompetitionTopic(raceCompetitionTopic);
    }

    /**
     * 修改竞赛试题
     * 
     * @param raceCompetitionTopic 竞赛试题
     * @return 结果
     */
    @Override
    public int updateRaceCompetitionTopic(RaceCompetitionTopic raceCompetitionTopic)
    {
        raceCompetitionTopic.setUpdateTime(DateUtils.getNowDate());
        return raceCompetitionTopicMapper.updateRaceCompetitionTopic(raceCompetitionTopic);
    }

    /**
     * 批量删除竞赛试题
     * 
     * @param ids 需要删除的竞赛试题主键
     * @return 结果
     */
    @Override
    public int deleteRaceCompetitionTopicByIds(Long[] ids)
    {
        return raceCompetitionTopicMapper.deleteRaceCompetitionTopicByIds(ids);
    }

    /**
     * 删除竞赛试题信息
     * 
     * @param id 竞赛试题主键
     * @return 结果
     */
    @Override
    public int deleteRaceCompetitionTopicById(Long id)
    {
        return raceCompetitionTopicMapper.deleteRaceCompetitionTopicById(id);
    }
}
